package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.basicAuditInstructionPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:basicAuditInstructionMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/10/2 14:55
 * @Version 1.0
 */
@Mapper
public interface basicAuditInstructionMapp {
    //插入一行审核块
    @DS("newMscLowCodeFormal")
    @Insert("insert into ddm_basic_audit_instruction (" +
            "id, create_time, update_time," +
            "creator, process_status, sys_update_user," +
            "sys_audit_user, sys_audit_time, sys_deleted," +
            "standard_module_name, audit_link, audit_project," +
            "audit_requirement, audit_instruction, problem_level," +
            "time, section, related_document1," +
            "related_document2, related_document3, iFTA_clause, " +
            "system_document_association)" +
            "values " +
            "(#{id}, #{create_time}, #{update_time}," +
            "#{creator}, #{process_status}, #{sys_update_user}," +
            "#{sys_audit_user}, #{sys_audit_time}, #{sys_deleted}," +
            "#{standard_module_name}, #{audit_link}, #{audit_project}," +
            "#{audit_requirement}, #{audit_instruction}, #{problem_level}," +
            "#{time}, #{section}, #{related_document1}," +
            "#{related_document2}, #{related_document3}, #{iFTA_clause}," +
            "#{system_document_association})")
    void insertOne(basicAuditInstructionPojo pojo);

    //修改一行审核块
    @DS("newMscLowCodeFormal")
    @Update("update ddm_basic_audit_instruction set " +
            "create_time=#{create_time}, " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +  // 这里补上逗号
            "process_status=#{process_status}, " +  // 这里补上逗号
            "sys_update_user=#{sys_update_user}, " +
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "standard_module_name=#{standard_module_name}, " +
            "audit_link=#{audit_link}, " +
            "audit_project=#{audit_project}, " +
            "audit_requirement=#{audit_requirement}, " +
            "audit_instruction=#{audit_instruction}, " +
            "problem_level=#{problem_level}, " +
            "time=#{time}, " +
            "section=#{section}, " +
            "related_document1=#{related_document1}, " +
            "related_document2=#{related_document2}, " +
            "related_document3=#{related_document3}, " +
            "iFTA_clause=#{iFTA_clause}, " +
            "system_document_association=#{system_document_association} " +
            "where id=#{id} ")
    void editOneById(basicAuditInstructionPojo pojo);

    //分页查询审核块
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_basic_audit_instruction where sys_deleted=0 " +
            "order by audit_link " +
            "limit #{startRow}, #{size}")
    List<basicAuditInstructionPojo> queryByPage(Integer startRow, Integer size);

    //查询所有审核块条数
    @DS("newMscLowCodeFormal")
    @Select("SELECT COUNT(*) FROM ddm_basic_audit_instruction where sys_deleted=0")
    Integer queryQuantity();

    //根据一个字段修改一个字段
    @DS("newMscLowCodeFormal")
    @Update("update ddm_basic_audit_instruction set " +
            "${fieldName}=#{fieldValue} " +
            "where id=#{id}")
    void editOneField(String id, String fieldName, String fieldValue);
}
